<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<template id="tp1">
  <div>
    我是儿子 我有
    <ccpn></ccpn>
  </div>
</template>

<template id="tp2">
  <div>
    我是孙子
    <button @click="gsonclick()">访问parent</button>
    <button @click="rootclick()">访问祖宗</button>
  </div>
</template>


<div id="app">
  <cpn></cpn>

</div>

<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
    el:"#app",
    data: {
      message:"stupid mother fucker"
    },
    components:{
      cpn:{
        template:'#tp1',
        data(){
          return{name:'mtf'}
        },
        components: {
          ccpn:{
            template:'#tp2',
            methods:{
              gsonclick(){
                console.log(this.$parent.name);
              },
              rootclick()
              {
                console.log(this.$root.message)
              }
            }
          }
        },
        methonds:{}
      }

    }
  })
</script>
</body>
</html>